package com.wdh.kjs.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.LinearLayout;
import android.widget.ScrollView;

import com.wdh.kjs.Adapter.ChooseBankCardAdapter;
import com.wdh.kjs.Adapter.ListViewForScrollView;
import com.wdh.kjs.R;
import com.wdh.kjs.model.data;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

/**
 * Created by chenqinhuang on 2016/4/21.
 */
public class ChooseBankActivity2 extends BaseTopActivity implements View.OnClickListener{
    private ScrollView choose_bank_scrollview;
    private ListViewForScrollView choose_bank_listview;
    private ChooseBankCardAdapter chooseBankCardAdapter;
    private List<HashMap<String, String>> datas=new ArrayList<>();
    private String[] bank={"农业银行","工商银行","建设银行","民生银行","兴业银行","交通银行","中信银行","平安银行","广发银行","招商银行","中国银行","浦发银行"};

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.fragment_choose_bandcard);
        initTopBar("选择银行卡");
        initview();
    }

    private void initview() {
        choose_bank_scrollview = (ScrollView)findViewById(R.id.choose_bank_scrollview);
        choose_bank_listview = (ListViewForScrollView)findViewById(R.id.choose_bank_listview);
        chooseBankCardAdapter = new ChooseBankCardAdapter(this,initListViewData());
        choose_bank_listview.setAdapter(chooseBankCardAdapter);
//        choose_bank_scrollview.smoothScrollTo(0,0);
        choose_bank_listview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                Intent intent = new Intent();
                intent.putExtra("bandCardType", bank[i]);
                intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                setResult(1,intent);
                finish();
            }
        });
    }

    private List<HashMap<String, String>> initListViewData() {
        datas = new ArrayList<>();
        for (int i = 0; i < bank.length; i++) {
            HashMap<String, String> hashMap = new HashMap<>();
                hashMap.put("choose_bank2_name", bank[i]);
                datas.add(hashMap);
        }
        return datas;

    }
    @Override
    public void onClick(View view) {
    }
}
